/*
 * BidTicket.java
 *
 * This program demonstrates the use of variable arguments and the
 * foreach loop to accept bids for a ticket. It also displays the highest bid.
 *
 
 */

package com.javacore.day3.bidding;

/**
 * BidTicket is a class that accepts bids for an airline ticket as variable
 * arguments and prints the highest bid.
 * 
 * @author
 */
public class BidTicket {

	/** Creates a new instance of BidTicket */
	public BidTicket() {
	}

	/**
	 * Method to accept variable arguments and display the highest bid.
	 * 
	 * @param bids
	 *            a parameter to hold the value of the bid.
	 */
	public void displayBids(double... bids) {

		/**
		 * Declaring an integer variable to count the number of bids.
		 */
		int noOfBids = 1;

		/**
		 * Declare a variable to store the highest bid for the ticket.
		 */
		double highestBid = 0;

		// Use the foreach loop to iterate through the arguments (bids)
		for (double value : bids) {
			System.out.println("Bid " + noOfBids + " = " + value);

			// Check for the highest bid
			if (value > highestBid) {
				highestBid = value;
			}
			noOfBids++;
		}
		System.out.println("\nThe highest bid received is: $" + highestBid);
	}
}
